<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
        function getAjax(ranUrl){
            return new Promise(function(resolve,reject){
                const xhr =new XMLHttpRequest()
                const httpUrl = ranUrl;
                xhr.open('GET',httpUrl)
            
            xhr.onreadystatechange = function(){
                if (xhr.status == 200 && xhr.readyState == 4) {
                    result = JSON.parse(xhr.response)
                    resolve(result)
                }else if(xhr.readyState == 4 && xhr.status != 200){
                    reject(xhr)
                }
            }
            xhr.send()

            })
        }




        async function getMusic(){
            const ranUrl = "https://api.apiopen.top/musicRankings";
            const ranRes = await getAjax(ranUrl)
            console.log(ranRes);
        }

        getMusic()
        


    </script>
    
</body>
</html>